<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                template="#{facesContext.externalContext.requestContextPath}../../resources/template/layout.xhtml">

    <ui:define name="content">

        <h:form id="frm-usuario" prependId="false">

            <p:toolbar id="toolbar">

                <p:toolbarGroup align="left">
                    <h1 class="titulo">
                        Formulário de Correspondências
                    </h1>
                </p:toolbarGroup>

                <p:toolbarGroup align="right">

                    <p:ajaxStatus style="float: left; width:16px; height:16px; margin: 7px 7px 0px 0px;">  

                        <f:facet name="start">  
                            <h:graphicImage value="#{facesContext.externalContext.requestContextPath}../../resources/img/ajax.gif" />  
                        </f:facet>  

                        <f:facet name="complete">  
                            <h:outputText value="" />  
                        </f:facet>  

                    </p:ajaxStatus>

                    <p:commandButton value="Salvar" 
                                     image="ui-icon ui-icon-check"
                                     action="#{correspondenciaBean.salvar()}"
                                     ajax="true"
                                     update="grid"
                                     tabindex="8"
                                     style="width: 90px; margin-right: 5px;" />

                    <p:commandButton value="Cancelar" 
                                     image="ui-icon ui-icon-close"
                                     immediate="true"
                                     ajax="true"
                                     action="list?faces-redirect=true"
                                     tabindex="9"
                                     style="width: 90px; margin-right: 5px;" />

                    <p:commandButton value="Limpar" 
                                     image="ui-icon ui-icon-refresh"
                                     immediate="true"
                                     ajax="true"
                                     type="reset"
                                     tabindex="10"
                                     style="width: 90px; margin-right: 5px;" />

                </p:toolbarGroup>

            </p:toolbar>

            <p:spacer height="15" />

            <p:panel id="panel" header="Dados da Correspondência">

                <h:panelGrid id="grid" columns="3" cellpadding="5">

                    <h:outputLabel for="entrada" value="Data Entrada: " />
                    <p:calendar id="entrada"
                                value="#{correspondenciaBean.correspondencia.dtaEntrada}"
                                maxlength="10"
                                style="width: 150px;"
                                pattern="dd/MM/yyyy"
                                navigator="true"
                                timeZone="GMT-3"
                                locale="pt_Br"
                                required="true"
                                tabindex="1"
                                label="Data Entrada" />
                    <p:message for="entrada" />

                    <h:outputLabel for="registro" value="Registro: " />
                    <p:inputMask id="registro"
                                 mask="aa999999999aa"
                                 value="#{correspondenciaBean.correspondencia.registro}"
                                 maxlength="13" 
                                 style="width: 150px;"
                                 required="true"
                                 tabindex="2"
                                 label="Registro" />
                    <p:message for="registro" />

                    <h:outputLabel for="tipo" value="Tipo: " />
                    <h:selectOneRadio id="tipo"
                                      value="#{correspondenciaBean.correspondencia.tipo}"
                                      required="true"
                                      tabindex="3"
                                      label="Tipo">
                        <f:selectItem id="reg" itemLabel="REG" itemValue="REG" />
                        <f:selectItem id="ar" itemLabel="AR" itemValue="AR" />
                        <f:selectItem id="mp" itemLabel="MP" itemValue="MP" />
                        <f:selectItem id="armp" itemLabel="AR/MP" itemValue="AR/MP" />
                    </h:selectOneRadio>
                    <p:message for="tipo" />

                    <h:outputLabel for="destinatario" value="Destinatário:" />
                    <p:autoComplete id="destinatario"
                                    value="#{correspondenciaBean.correspondencia.destinatario}"
                                    var="destinatario"
                                    itemValue="#{destinatario}"
                                    itemLabel="#{destinatario.nome}"
                                    converter="moradorConverter"
                                    maxlength="50"
                                    style="width: 400px;"
                                    minQueryLength="3"
                                    maxResults="10"
                                    queryDelay="500"
                                    completeMethod="#{correspondenciaBean.autoCompletar}"
                                    required="true"
                                    label="Destinatário"
                                    tabindex="4" />
                    <p:message for="destinatario" />

                    <h:outputLabel for="entrega" value="Data Entrega/Devolução: " />
                    <p:calendar id="entrega"
                                value="#{correspondenciaBean.correspondencia.dtaEntrega}"
                                maxlength="10"
                                style="width: 150px;"
                                pattern="dd/MM/yyyy"
                                navigator="true"
                                timeZone="GMT-3"
                                locale="pt_Br"
                                required="false"
                                tabindex="5"
                                label="Data Entrega/Devolução" />
                    <p:message for="entrega" />

                    <h:outputLabel for="recebido" value="Recebido por:" />
                    <p:inputText id="recebido"
                                 value="#{correspondenciaBean.correspondencia.recebido}"
                                 maxlength="50"
                                 style="width: 400px;"
                                 required="false"
                                 label="Recebido por"
                                 tabindex="6" />
                    <p:message for="recebido" />

                    <h:outputLabel for="motivo" value="Motivo da Devolução:" />
                    <h:inputTextarea id="motivo"
                                     value="#{correspondenciaBean.correspondencia.motivo}"
                                     required="false"
                                     tabindex="7"
                                     label="Motivo" />
                    <p:message for="motivo" />

                </h:panelGrid>

            </p:panel>

        </h:form>

    </ui:define>

</ui:composition>